﻿import { _tips2, _refresh } from 'util';

export default {
    data() {
        return {
            //初始值
            loading: false,
            //默认值
            selectList: [],
            selectKey: "id",
            detailKey: "id",
            //改动比较大
            isRefresh: false,
            pages: [], //监听的子页面
        }
    },
    mounted(){
        // console.log('isRefresh',this.isRefresh,this.bus);
        this.isRefresh && this.bus.$on('refresh', this._refresh);
    },
    beforeDestroy(){
        this.isRefresh && this.bus.$off('refresh',this._refresh);
    },
    methods: {
        GetList(callback){
            this.$refs.searchFrom && this.$refs.searchFrom.GetList(callback);
        },
        _tips2,
        _refresh,
        select_change(selection){
            this.selectList = selection;
        },
        go_detail(row,status=1,query={},params={}){
            let id = row && row[this.detailKey] || '0';
            query = Object.assign(query,{s:String(status)});
            params = Object.assign(params,{id: String(id)});
            this.$go({
                name: this.pages[0],
                replace:false,
                params:params,
                query: query
            }, this.$router,1);
        },
        go_views(row,key=0,query={},params={}){
            let id = row && row[this.detailKey] || '0';
            params = Object.assign(params,{id: String(id)});
            this.$go({
                name: this.pages[key],
                replace:false,
                params,
                query
            }, this.$router,1);
        },
        _getSelectIds(){
            let ids = '';
            let msg = "";
            if(!this.selectList.length) msg = "请选择操作项";
            if(msg) {
                this.$tipsMessage(msg,2);
                return ids;
            };
            ids = this.selectList.map((el,ix) => {
                return el[this.selectKey]; //id
            }).join(',')
            return ids;
        },
        beforeApiFn(){
            this.selectList = [];
        },
    },
}
